﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


namespace Tetris
{
    class Factory
    {
       public Shape MakeShape(GameField ff)
       {
           Shape n = null;
           Random rnd = new Random();
           int m = rnd.Next(0, 5);
           switch (m)
           {
               case 0:
                   n=CreateZig1(ff);
                   break;
               case 1:
                   n = CreateZig2(ff);
                   break;
               case 2:
                   n = CreateLine(ff);
                   break;
               case 3:
                   n = CreateBlock(ff);
                   break;
               case 4:
                   n = CreateCorner1(ff);
                   break;
               default:
                   n = CreateCorner2(ff);
                   break;
           }
           return n;
           
       }
       private Zig1 CreateZig1(GameField ff)
       {
           Point first = new Point(ff.Widths / 2, 0);
           Point second = new Point(ff.Widths / 2, 1);
           Point third = new Point(ff.Widths / 2 + 1, 1);
           Point fourth = new Point(ff.Widths / 2 + 1, 2);
           Zig1 test = new Zig1(first, second, third, fourth);
           return test;
       }
       private Zig2 CreateZig2(GameField ff)
       {
           Point first = new Point(ff.Widths / 2, 0);
           Point second = new Point(ff.Widths / 2, 1);
           Point third = new Point(ff.Widths / 2 - 1, 1);
           Point fourth = new Point(ff.Widths / 2 - 1, 2);
           Zig2 test = new Zig2(first, second, third, fourth);
           return test;
       }
       private Block CreateBlock(GameField ff)
       {
           Point first = new Point(ff.Widths / 2, 0);
           Point second = new Point(ff.Widths / 2+1, 0);
           Point third = new Point(ff.Widths / 2, 1);
           Point fourth = new Point(ff.Widths / 2 + 1, 1);
           Block test = new Block(first, second, third, fourth);
           return test;
       }
       private Corner1 CreateCorner1(GameField ff)
       {
           Point first = new Point(ff.Widths / 2+1, 0);
           Point second = new Point(ff.Widths / 2, 0);
           Point third = new Point(ff.Widths / 2, 1);
           Point fourth = new Point(ff.Widths / 2, 2);
           Corner1 test = new Corner1(first, second, third, fourth);
           return test;
       }
       private Corner2 CreateCorner2(GameField ff)
       {
           Point first = new Point(ff.Widths / 2-1, 0);
           Point second = new Point(ff.Widths / 2, 0);
           Point third = new Point(ff.Widths / 2, 1);
           Point fourth = new Point(ff.Widths / 2, 2);
           Corner2 test = new Corner2(first, second, third, fourth);
           return test;
       }
       private Line CreateLine(GameField ff)
       {
           Point first = new Point(ff.Widths / 2, 0);
           Point second = new Point(ff.Widths / 2, 1);
           Point third = new Point(ff.Widths / 2, 2);
           Point fourth = new Point(ff.Widths / 2, 3);
           Line test = new Line(first, second, third, fourth);
           return test;
       }
    }
}
